package com.jnevision.role.service;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jnevision.role.mapper.RoleMapper;
import com.jnevision.role.model.Role;

/**
 * <p>
 * 角色 服务实现类
 * </p>
 *
 * @author gavin
 * @since 2019-07-13
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> {

    @Autowired
    private RoleMapper roleMapper;

    public Collection<Role> getRole(String userId) {
        List<Integer> roleIds = this.roleMapper.getRole(userId);
        if (!CollectionUtils.isEmpty(roleIds)) {
            return this.listByIds(roleIds);
        }
        return Collections.emptyList();
    }
}
